package sostats.core.base;

import sostats.core.help.Tuple;

public class Joint implements Tuple<String,String>{
	private Attribute fk;
	private Attribute pk;
	public Joint(String fk, String pk) {
		this.fk = new Attribute(fk);
		this.pk = new Attribute(pk);
	}

	@Override
	public int hashCode() {
		final int prime = 31;
		int result = 1;
		result = prime * result + ((fk == null) ? 0 : fk.hashCode());
		result = prime * result + ((pk == null) ? 0 : pk.hashCode());
		return result;
	}
	@Override
	public boolean equals(Object obj) {
		if (this == obj)
			return true;
		if (obj == null)
			return false;
		if (getClass() != obj.getClass())
			return false;
		Joint other = (Joint) obj;
		if (fk == null) {
			if (other.fk != null)
				return false;
		} else if (!fk.equals(other.fk))
			return false;
		if (pk == null) {
			if (other.pk != null)
				return false;
		} else if (!pk.equals(other.pk))
			return false;
		return true;
	}

	@Override
	public String getFirst() {
		return fk.getName();
	}

	@Override
	public String getSecond() {
		return pk.getName();
	}
	
}
